import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
// 导入插件
import TreeTable from 'vue-table-with-tree-grid'

// 导入nprogress
import { NProgress } from 'nprogress'
import 'nprogress/nprogress.css'

// 导入axios
import axios from 'axios'
// 配置baseURL
axios.defaults.baseURL = 'https://lianghj.top:8888/api/private/v1/'
// 添加到vue.prototype.$http后,可以在每一个组件上通过this.$http获取axios 不必每个页面都import  axios   $http是自定义的属性名,可以随便起
Vue.prototype.$http = axios


// axios请求拦截
axios.interceptors.request.use(config => {
  NProgress.start()
  // 为请求头对象添加token验证authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})


axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})

Vue.config.productionTip = false

Vue.component('tree-table', TreeTable)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
